﻿using System;
using IQToolkit;
using IQToolkit.Data;
using IQToolkit.Data.Mapping;
using IQToolkit.Data.MySqlClient;
using TimeSplicerModule.DataModels;

namespace TimeSplicerModule.Database
{
    // After im done will need to create an interface

    public class Timesplicer
    {
        private IEntityProvider _provider;

        public Timesplicer(IEntityProvider provider)
        {
            this._provider = provider;
        }

        public IEntityProvider Provider
        {
            get { return this._provider; }
            set { this._provider = value; }
        }

        // TABLES
        [Table(Name = "Priorities")]
        [Column(Member = "PriorityGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "PriorityName")]
        [Column(Member = "PriorityNameEnum")]
        [Column(Member = "Level", Name = "ImportanceLevel")]
        [Column(Member = "SortOrder")]
        [Column(Member = "IsActive")]
        public virtual IEntityTable<PriorityDataModel> Priorities
        {
            get { return this.Provider.GetTable<PriorityDataModel>("Priorities"); }
        }


        [Table(Name = "Statuses")]
        [Column(Member = "StatusGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "StatusName")]
        [Column(Member = "StatusEnum")]
        [Column(Member = "IsActive")]
        [Column(Member = "IsUserStatus")]
        [Column(Member = "IsProjectStatus")]
        [Column(Member = "IsBranchStatus")]
        [Column(Member = "IsTaskStatus")]
        [Column(Member = "StatusColor")]
        [Column(Member = "SortOrder")]
        public virtual IEntityTable<StatusDataModel> Statuses
        {
            get { return this.Provider.GetTable<StatusDataModel>("Statuses"); }
        }


        [Table(Name = "ApplicationItems")]
        [Column(Member = "ApplicationItemGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "ItemName")]
        [Column(Member = "ItemEnum")]
        [Column(Member = "Description")]
        public virtual IEntityTable<ApplicationItemDataModel> ApplicationItems
        {
            get { return this.Provider.GetTable<ApplicationItemDataModel>("ApplicationItems"); }
        }


        [Table(Name = "ApplicationPermissions")]
        [Column(Member = "ApplicationPermissionGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "PermissionName")]
        [Column(Member = "PermissionEnum")]
        [Column(Member = "IsApplicationRolePermission")]
        [Column(Member = "IsProjectRolePermission")]
        [Column(Member = "Hierarchy")]
        [Column(Member = "IsActive")]
        public virtual IEntityTable<ApplicationPermissionDataModel> ApplicationPermissions
        {
            get { return this.Provider.GetTable<ApplicationPermissionDataModel>("ApplicationPermissions"); }
        }


        [Table(Name = "ApplicationRoles")]
        [Column(Member = "ApplicationRoleGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "RoleName")]
        [Column(Member = "Description")]
        [Column(Member = "Hierarchy")]
        [Column(Member = "IsActive")]
        public virtual IEntityTable<ApplicationRoleDataModel> ApplicationRoles
        {
            get { return this.Provider.GetTable<ApplicationRoleDataModel>("ApplicationRoles"); }
        }



        [Table(Name = "ApplicationRolePermissions")]
        [Column(Member = "ApplicationRolePermissionGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ApplicationRoleGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ApplicationItemGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ApplicationPermissionGuid")]
        public virtual IEntityTable<ApplicationRolePermissionDataModel> ApplicationRolePermissions
        {
            get { return this.Provider.GetTable<ApplicationRolePermissionDataModel>("ApplicationRolePermissions"); }
        }


        [Table(Name = "Categories")]
        [Column(Member = "CategoryGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ParentCategoryGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "CategoryName")]
        [Column(Member = "IsActive")]
        [Column(Member = "Description")]
        [Column(Member = "IsProjectCategory")]
        [Column(Member = "IsBranchCategory")]
        [Column(Member = "IsTaskCategory")]
        [Column(Member = "IsTaskSubCategory")]
        [Column(Member = "IsGlobal")]
        public virtual IEntityTable<CategoryDataModel> Categories
        {
            get { return this.Provider.GetTable<CategoryDataModel>("Categories"); }
        }


        [Table(Name = "Teams")]
        [Column(Member = "TeamGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ParentTeamGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "TeamName")]
        [Column(Member = "Acronym")]
        [Column(Member = "Y", Name = "DimensionY")]
        [Column(Member = "X", Name = "DimensionX")]
        [Column(Member = "IsActive")]
        public virtual IEntityTable<TeamDataModel> Teams
        {
            get { return this.Provider.GetTable<TeamDataModel>("Teams"); }
        }


        [Table(Name = "TeamCategories")]
        [Column(Member = "TeamCategoryGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "CategoryGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "TeamGuid", DbType = "VARCHAR(36)")]
        public virtual IEntityTable<TeamCategoryDataModel> TeamCategories
        {
            get { return this.Provider.GetTable<TeamCategoryDataModel>("TeamCategories"); }
        }


        [Table(Name = "Users")]
        [Column(Member = "UserGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "StatusGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ApplicationRoleGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "TeamGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "JobRoleGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "Login")]
        [Column(Member = "Password", Name = "LoginPassword")]
        [Column(Member = "FirstName")]
        [Column(Member = "LastName")]
        public virtual IEntityTable<UserDataModel> Users
        {
            get { return this.Provider.GetTable<UserDataModel>("Users"); }
        }



        [Table(Name = "Timestamps")]
        [Column(Member = "TimestampGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "TaskGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "StampNumber")]
        [Column(Member = "StartTime")]
        [Column(Member = "EndTime")]
        [Column(Member = "TimestampTypeEnum")]
        public virtual IEntityTable<TimestampDataModel> Timestamps
        {
            get { return this.Provider.GetTable<TimestampDataModel>("Timestamps"); }
        }

        [Table(Name = "ProjectRoles")]
        [Column(Member = "ProjectRoleGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "RoleName")]
        [Column(Member = "Description")]
        [Column(Member = "Hierarchy")]
        public virtual IEntityTable<ProjectRoleDataModel> ProjectRoles
        {
            get { return this.Provider.GetTable<ProjectRoleDataModel>("ProjectRoles"); }
        }


        [Table(Name = "ProjectUsers")]
        [Column(Member = "ProjectUserGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ProjectGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "UserGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ProjectRoleGuid", DbType = "VARCHAR(36)")]
        public virtual IEntityTable<ProjectUserDataModel> ProjectUsers
        {
            get { return this.Provider.GetTable<ProjectUserDataModel>("ProjectUsers"); }
        }



        [Table(Name = "Projects")]
        [Column(Member = "ProjectGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "CategoryGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "PriorityGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "StatusGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "ProjectName")]
        [Column(Member = "Description")]
        [Column(Member = "EstimatedHours")]
        [Column(Member = "StartedDate")]
        [Column(Member = "DueDate")]
        [Column(Member = "CompletedDate")]
        [Column(Member = "CreatedDate")]
        [Column(Member = "CreatedByGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ProjectManagerGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "IsBucket")]
        [Column(Member = "ActualHours")]
        public virtual IEntityTable<ProjectDataModel> Projects
        {
            get { return this.Provider.GetTable<ProjectDataModel>("Projects"); }
        }



        [Table(Name = "Tasks")]
        [Column(Member = "TaskGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ProjectGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "CategoryGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "SubCategoryGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "PriorityGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "Name", Name = "TaskName")]
        [Column(Member = "Description")]
        [Column(Member = "EstimatedHours")]
        [Column(Member = "StartedDate")]
        [Column(Member = "DueDate")]
        [Column(Member = "CompletedDate")]
        [Column(Member = "CreatedDate")]
        [Column(Member = "CreatedByGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "AssignedToGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "IsRecurring")]
        [Column(Member = "StatusGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ActualHours")]
        [Column(Member = "LastWorked")]
        [Column(Member = "IsDerived")]
        [Column(Member = "DerivedFromTaskGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "ScheduledDate")]
        public virtual IEntityTable<TaskDataModel> Tasks
        {
            get { return this.Provider.GetTable<TaskDataModel>("Tasks"); }
        }

        [Table(Name = "TaskSchedules")]
        [Column(Member = "ScheduleGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "TaskGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "OccuranceType")]
        [Column(Member = "IncludeSunday")]
        [Column(Member = "IncludeMonday")]
        [Column(Member = "IncludeTuesday")]
        [Column(Member = "IncludeWednesday")]
        [Column(Member = "IncludeThursday")]
        [Column(Member = "IncludeFriday")]
        [Column(Member = "IncludeSaturday")]
        [Column(Member = "AutoStart")]
        [Column(Member = "StartDate")]
        [Column(Member = "StartHour")]
        [Column(Member = "StartMinute")]
        [Column(Member = "StartAmPm")]
        [Column(Member = "EndDate")]
        [Column(Member = "EndHour")]
        [Column(Member = "EndMinute")]
        [Column(Member = "EndAmPm")]
        [Column(Member = "IsActive")]
        public virtual IEntityTable<TaskScheduleDataModel> TaskSchedules
        {
            get { return this.Provider.GetTable<TaskScheduleDataModel>("TaskSchedules"); }
        }

        [Table(Name = "ScheduledTasks")]
        [Column(Member = "ScheduledTaskGuid", IsPrimaryKey = true, DbType = "VARCHAR(36)")]
        [Column(Member = "ScheduleGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "TaskInstanceGuid", DbType = "VARCHAR(36)")]
        [Column(Member = "InstanceNumber")]
        [Column(Member = "IsCompleted")]
        [Column(Member = "StartDate")]
        [Column(Member = "CompletedDate")]
        public virtual IEntityTable<ScheduledTaskDataModel> ScheduledTasks
        {
            get { return this.Provider.GetTable<ScheduledTaskDataModel>("ScheduledTasks"); }
        }
    }
}
